const express = require('express')
const app = express()
const list = [
  {
    id: 1,
    name: '张三',
    age: 18
  },
  {
    id: 2,
    name: '李四',
    age: 19
  },
  {
    id: 3,
    name: '王五',
    age: 30
  }
]
// 创建路由
app.get('/:id', (req, res) => {
  const id = req.params.id
  const data = list.find(v => +id === v.id)
  res.json(data)
  // res.end()
})

app.listen(3000, () => {
  console.log('启动成功！')
})